<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>粘性定位</title>
    <style>
        body {
            height: 3000px;
        }
        .page-header {
          height: 100px;
          font-size: 20px;
          line-height: 100px;
          text-align: center;
          background-color: orange;
        }
        .content {
          background-color: grey;
        }
        .first {
          background-color: skyblue;
          font-size: 40px;
          /* 开启粘性定位 */
          position: sticky;
          /* 粘性定位的位置 参考点：第一个可滚动的父元素，即使这个祖先不是真实可滚动的祖先 可以设置外边框和开启浮动但不建议 */
          top: 0px;
          float: right;
          margin-right: 100px;
        }
    </style>
</head>
<body>
  <div class="page-header">头部</div>
  <div class="content">
    <div class="item">
      <div class="first">A</div>
      <h2>A1</h2>
      <h2>A2</h2>
      <h2>A3</h2>
      <h2>A4</h2>
      <h2>A5</h2>
      <h2>A6</h2>
      <h2>A7</h2>
      <h2>A8</h2>
      <div class="first">B</div>
      <h2>B1</h2>
      <h2>B2</h2>
      <h2>B3</h2>
      <h2>B4</h2>
      <h2>B5</h2>
      <h2>B6</h2>
      <h2>B7</h2>
      <h2>B8</h2>
      <div class="first">C</div>
      <h2>C1</h2>
      <h2>C2</h2>
      <h2>C3</h2>
      <h2>C4</h2>
      <h2>C5</h2>
      <h2>C6</h2>
      <h2>C7</h2>
      <h2>C8</h2>
    </div>
  </div>
</body>
</html>